package io.plus.user_interface.io.common.packet;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

@Data
public class ChatMessage extends RequestMessage {
    private static final long serialVersionUID = 5731474214655476286L;
    /**
     * 发送用户id;
     */
    private String from;
    /**
     * 目标用户id;
     */
    private String to;
    /**
     * 消息类型;(如：0:text、1:image、2:voice、3:vedio、4:music、5:news)
     */
    private Integer messageType;
    /**
     * 聊天类型;(如公聊、私聊)
     */
    private Integer chatType;
    /**
     * 消息内容;
     */
    private String content;
    /**
     * 消息发到哪个群组;
     */
    private String groupId;

    private ChatMessage() {
    }

    private ChatMessage(String id, String from, String to, Integer msgType, Integer chatType, String content, String groupId, Integer cmd, Long createTime, JSONObject extras) {
        this.id = id;
        this.from = from;
        this.to = to;
        this.messageType = msgType;
        this.chatType = chatType;
        this.content = content;
        this.groupId = groupId;
        this.cmd = cmd;
        this.createTime = createTime;
        this.extras = extras;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public byte[] toByte() {
        return null;
    }

    public ChatMessage setChatType(Integer chatType) {
        this.chatType = chatType;
        return this;
    }

    public ChatMessage setContent(String content) {
        this.content = content;
        return this;
    }

    public ChatMessage setFrom(String from) {
        this.from = from;
        return this;
    }

    public ChatMessage setGroupId(String groupId) {
        this.groupId = groupId;
        return this;
    }

    public ChatMessage setMessageType(Integer messageType) {
        this.messageType = messageType;
        return this;
    }

    public ChatMessage setTo(String to) {
        this.to = to;
        return this;
    }

    @Data
    public static class Builder extends RequestMessage.Builder<ChatMessage, Builder> {
        /**
         * 来自user_id;
         */
        private String from;
        /**
         * 目标user_id;
         */
        private String to;
        /**
         * 消息类型;(如：0:text、1:image、2:voice、3:vedio、4:music、5:news)
         */
        private Integer messageType;
        /**
         * 聊天类型;(如公聊、私聊)
         */
        private Integer chatType;
        /**
         * 消息内容;
         */
        private String content;
        /**
         * 消息发到哪个群组;
         */
        private String groupId;

        public Builder() {
        }

        @Override
        public ChatMessage build() {
            return new ChatMessage(this.id, this.from, this.to, this.messageType, this.chatType, this.content, this.groupId, this.cmd, this.createTime, this.extras);
        }

        @Override
        protected Builder getThis() {
            return this;
        }

        public Builder setChatType(Integer chatType) {
            this.chatType = chatType;
            return this;
        }

        public Builder setContent(String content) {
            this.content = content;
            return this;
        }

        public Builder setFrom(String from) {
            this.from = from;
            return this;
        }

        public Builder setGroup_id(String group_id) {
            this.groupId = group_id;
            return this;
        }

        public Builder setMsgType(Integer msgType) {
            this.messageType = msgType;
            return this;
        }

        public Builder setTo(String to) {
            this.to = to;
            return this;
        }
    }
}
